#!/bin/sh
# $Id$
#
# chkconfig: 2345 70 40
# description: cmetricd startup script
#
### BEGIN INIT INFO
# Provides:       cmetricd
# Required-Start: $gmond
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    Feeds Ganglia with custom cluster metrics information
### END INIT INFO

CMETRICD=/usr/sbin/cmetricd

if [ -e /etc/init.d/functions ]; then
    . /etc/init.d/functions
fi

RETVAL=0

case "$1" in
   start)
      echo -n "Starting cluster metrics feeder cmetricd: "
      [ -f $CMETRICD ] || exit 1

      daemon $CMETRICD
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cmetricd
	;;

  stop)
      echo -n "Shutting down cluster metrics feeder cmetricd: "
      killproc cmetricd
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cmetricd
	;;

  restart|reload)
   	$0 stop
   	$0 start
   	RETVAL=$?
	;;
  status)
   	status cmetricd
   	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL
